/*
    Nios-sim - one simple NIOSII simulator only for personal interest and fun.
    Copyright (C) 2010  chysun2000@gmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __TIMER_H__
#define __TIMER_H__

#include <stdio.h>
#include "public.h"
#include "niosii.h"
#include "io_device.h"

#define TIMER_REG_CNT (6)
#define TIMER_BASE_ADDR (0x80681020)

#define CTRL_ITO_MASK (0x01)
#define CTRL_CONT_MASK (0x02)
#define CTRL_START_MASK (0x04)
#define CTRL_STOP_MASK (0x08)

#define STATUS_TO_MASK (0x01)
#define TIM_IRQ_MASK (1 << 3)
struct timer_hw{
	struct io_reg io_regs[TIMER_REG_CNT];
	uint32_t set_period;
	uint32_t curr_count;
	
};

/* the index */
#define TIM_REG_STATUS (0)
#define TIM_REG_CTRL (1)
#define TIM_REG_PERIODL (2)
#define TIM_REG_PERIODH (3)
#define TIM_REG_SNAPL (4)
#define TIM_REG_SNAPH (5)
	
extern struct io_device timer_core;
#endif

